/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Game={
    create:function () {
        var game={};
       game.ui=new PIXI.DisplayObjectContainer();
       var page0=Page0.create();

        game.ui.addChild(page0.ui);
        page0.In();

        var con=new PIXI.DisplayObjectContainer();
        var arr_page=[];
        var page1=Page1.create();
        page1.ui.x=1136*0;
        var page2=Page2.create();
        page2.ui.x=1136*1;
        var page3=Page3.create();
        page3.ui.x=1136*2;
        var page4=Page4.create();
        page4.ui.x=1136*3;
        arr_page.push(page1,page2,page3,page4);
        con.addChild(page1.ui);
        con.addChild(page2.ui);
        con.addChild(page3.ui);
        con.addChild(page4.ui);
        var sc=Scroller.create(con,pixiStageW,pixiStageH,'hor','AA',arr_page);

        document.addEventListener('AA_ScrollStart',startHandler);
        document.addEventListener('AA_ScrollComplete',completeHandler);

        function startHandler(e) {
            sc.arrPage[e.detail].Out()
        }
        function completeHandler(e) {
            sc.arrPage[e.detail].In()
        }


        document.addEventListener('Game_PageIn',pageInHandler)
        function pageInHandler(e)
        {
            if(e.detail=='0')
            {
                game.ui.removeChild(page0.ui);

                var p1_bg=Easy.CreateSprite('assets/images/p1_bg.png',1136/2,540/2,0.5,0.5,1);
                game.ui.addChild(p1_bg);
                p1_bg.scale.x=p1_bg.scale.y=1.5;
                TweenMax.to(p1_bg.scale,1,{x:1,y:1,alpha:1,ease:Cubic.easeInOut});
                TweenMax.to(p1_bg,1,{alpha:1,ease:Cubic.easeInOut});

                game.ui.addChild(con);
                // con.x=1136*3;
                arr_page[0].In();
            }

        }
        return game;
    }

}